<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/10/28
 * Time: 8:50
 */
namespace app\team\controller;

use think\Controller;
use think\Request;
use think\Db;
use think\Session;
use app\team\model\Comment as App;
class Comment extends Common
{
    public function comment()
    {
        //获取数据库的信息用于展示
        if (Request::instance()->isAjax()) {
            $pagedata = Request::instance()->get();
            $pagesize = $pagedata['limit'];
            $page = (int)$pagedata['page'];
            if ($page == 1) {
                $startrow = 0;
            } else {
                $startrow = ($page - 1) * $pagesize;
            }
            $where['is_display'] = array('eq',0);
            //$where['item_id'] = Session::get('team')['team_id'];
            $where['type'] = array('eq',3);
            if (isset($pagedata['nickname']) && $pagedata['nickname'] != '') {
                $where['nickname'] = array('like', '%' . $pagedata['nickname'] . '%');
            }
            if (isset($pagedata['content']) && $pagedata['content'] != '') {
                $where['content'] = array('like', '%' . $pagedata['content'] . '%');
            }
            $count = App::getAppraiseCount($where);
            $data =  App::getAppList($where,$startrow,$pagesize);
            return json(array('code' => 0, 'msg' => '请求成功', 'count' => $count, 'data' => $data));

        } else {
            return view();
        }
    }
}